<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib prefix="c"      uri="http://java.sun.com/jsp/jstl/core" %>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        
        <script >
            function refreshIframe(){
              document.all.refreshMsg.innerText="Loading....";
	      document.frmPortlet.action="portletViewer.htm?rand=" + Math.round(1000 * Math.random());
    	      document.frmPortlet.submit();
            }
            function getMsgInfo(msgId){
                //alert("In metho in Viewer");
                parent.getAllMsgInfo(msgId);
               // alert("out metho in Viewer");
            }
            
            function fnIgnoreMsg(){
                var lenChecked = 0;
                var totalMsgs =  document.frmPortlet.countNumbers.value * 1;
                var msgIds = "";
                
                if ( totalMsgs == 0 ) {
                    return;
                }else if ( totalMsgs == 1 ) {
                    msgIds = document.frmPortlet.checkMsg.value;
                }else{             
                    lenChecked = document.frmPortlet.checkMsg.length;
                    for (var i = 0; i < lenChecked; i++ ){
                        if ( document.frmPortlet.checkMsg[i].checked ) {
                            msgIds = msgIds + document.frmPortlet.checkMsg[i].value + ",";
                        }
                    }
                    msgIds = msgIds.substring(0,msgIds.length-1);
                }
                    
                if (msgIds == "" ) {
                   alert("Please select a Message to Ignore");
                    return;
                }
             
                document.frmPortlet.msgIds.value = msgIds; 
                document.frmPortlet.action="ignoreMessage.htm";
                document.frmPortlet.submit();
            }
        </script>
    </head>
    <body>
        <form name="frmPortlet"  method="post" action="portletViewer.htm">
        <span id="refreshMsg" style="position: absolute; height: 50px;width: 50px"></span>
        <table>
            <tr>
                <td colspan="4" align="right"><input type="button" value="Ignore" onclick="fnIgnoreMsg();"></td>
            </tr>
            <tr>
                <TH>Status</TH>
                <TH>Text</TH>
                <TH>Number</TH>
                <TH>Received Date</TH>
                <TH>Action</TH>
            </tr>
             <c:set var="i" value="0" />
            <c:forEach var="msg" items="${inpuMsgList}" >
                   <c:set var="i" value="${i + 1}" />
                <tr>
                    <td></td>
                    <td><a href="javascript:getMsgInfo(<c:out value="${msg.id}"/>)"><c:out value="${msg.text}"/></a></td>           
                    <td><c:out value="${msg.inputPhoneNumber}"/></td>             
                    <td><c:out value="${msg.createDate}"/></td>             
                    <td><input type="checkbox" value="<c:out value="${msg.id}"/>" name="checkMsg"></td>
                </tr>   
            </c:forEach>
            <input type="hidden" name="msgIds" value="">
            <input type="hidden" name="countNumbers" value="0";
        </table>
        <script>
            window.setInterval("refreshIframe()", 30000);
            document.frmPortlet.countNumbers.value =${i};
        </script>
        </form>
    </body>
</html>
